<?php
/**
 * Eka Framework 0.3.0
 *
 * @copyright Copyright (c) 2008 Alexey Yu. Chuprina <656b61@gmail.com> (http://php-eka.googlecode.com)
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 *
 * @version $Id$
 */

require_once 'Eka/Session/Abstract.php';

/**
 * Eka_Session
 *
 * @package Session
 */
class Eka_Session extends Eka_Session_Abstract
{

	protected function init()
	{
		foreach ($this->options as $key => $value) {
			switch ($key) {
				case 'name':
					session_name($value);
					break;
			}
		}
		session_start();
	}
	
	public function getId()
	{
		return session_id();
	}
	
	public function setId($value)
	{
		session_write_close();
		session_id($value);
		session_start();
	}
	
	public function __get($key)
	{
		return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
	}

	public function __set($key, $value)
	{
		$_SESSION[$key] = $value;
	}
	
	public function __isset($key)
	{
		return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
	}
	
	public function __unset($key)
	{
		unset($_SESSION[$key]);
	}
}